<template>
  <view class="container">
    <!-- 数据统计卡片 -->
    <view class="stat-card">
      <view class="stat-item">
        <text class="stat-value">15</text>
        <text class="stat-label">本月消毒次数</text>
      </view>
      <view class="stat-item">
        <text class="stat-value">84</text>
        <text class="stat-label">消毒覆盖率%</text>
      </view>
    </view>

    <!-- 消毒记录列表 -->
    <view class="record-list">
      <view v-for="(item, index) in disinfectionData" :key="index" class="record-card">
        <view class="card-header">
          <text class="date">{{ item.date }}</text>
          <text :class="['type', typeClass(item.type)]">{{ item.type }}</text>
        </view>
        
        <view class="card-body">
          <view class="info-item">
            <text class="label">消毒药品：</text>
            <text class="value">{{ item.chemical }}</text>
          </view>
          <view class="info-item">
            <text class="label">浓度比例：</text>
            <text class="value">{{ item.concentration }}</text>
          </view>
          <view class="info-item">
            <text class="label">负责人：</text>
            <text class="value">{{ item.operator }}</text>
          </view>
          <view class="info-item" v-if="item.remark">
            <text class="label">备注：</text>
            <text class="value remark">{{ item.remark }}</text>
          </view>
        </view>
        
        <view class="time-axis">
          <text class="time">{{ item.startTime }}</text>
          <text class="duration">{{ item.duration }}分钟</text>
        </view>
      </view>
    </view>

    <!-- 空状态提示 -->
    <view v-if="disinfectionData.length === 0" class="empty-tips">
      <image src="/static/empty.png" class="empty-img" />
      <text class="empty-text">暂无消毒记录</text>
    </view>

    <!-- 新增按钮 -->
    <view class="add-btn" @click="navigateToAdd">
      <uni-icons type="plusempty" size="24" color="#fff" />
    </view>
  </view>
</template>

<script setup>
import { ref } from 'vue';

// 模拟数据
const disinfectionData = ref([
  {
    date: '2024-03-15',
    type: '常规消毒',
    chemical: '过氧乙酸',
    concentration: '1:200',
    operator: '张三',
    startTime: '14:30',
    duration: 45,
    remark: '重点消毒饮水系统'
  },
  {
    date: '2024-03-10',
    type: '突击消毒',
    chemical: '次氯酸钠',
    concentration: '0.5%',
    operator: '李四',
    startTime: '09:00',
    duration: 60
  }
]);

// 消毒类型样式映射
const typeClass = (type) => {
  const typeMap = {
    '常规消毒': 'routine',
    '突击消毒': 'emergency',
    '终末消毒': 'terminal'
  };
  return typeMap[type] || 'routine';
};

const navigateToAdd = () => {
  uni.navigateTo({
    url: '/pages/distinfect/distinfect'
  });
};
</script>

<style scoped lang="scss">
.container {
  padding: 20rpx;
  min-height: 100vh;
  background: #f5f5f5;
}

.stat-card {
  background: #fff;
  border-radius: 16rpx;
  padding: 30rpx;
  display: flex;
  justify-content: space-around;
  margin-bottom: 30rpx;
  box-shadow: 0 4rpx 12rpx rgba(0,0,0,0.05);

  .stat-item {
    text-align: center;
    
    .stat-value {
      display: block;
      font-size: 42rpx;
      color: #333;
      font-weight: bold;
    }

    .stat-label {
      font-size: 24rpx;
      color: #666;
    }
  }
}

.record-list {
  .record-card {
    background: #fff;
    border-radius: 12rpx;
    margin-bottom: 24rpx;
    padding: 24rpx;
    box-shadow: 0 2rpx 8rpx rgba(0,0,0,0.05);

    .card-header {
      display: flex;
      justify-content: space-between;
      align-items: center;
      margin-bottom: 20rpx;

      .date {
        font-size: 28rpx;
        color: #666;
      }

      .type {
        font-size: 26rpx;
        padding: 8rpx 16rpx;
        border-radius: 8rpx;

        &.routine {
          background: #e8f5e9;
          color: #2e7d32;
        }

        &.emergency {
          background: #fff3e0;
          color: #ef6c00;
        }

        &.terminal {
          background: #fbe9e7;
          color: #d32f2f;
        }
      }
    }

    .card-body {
      .info-item {
        display: flex;
        margin-bottom: 16rpx;

        .label {
          width: 160rpx;
          color: #999;
          font-size: 26rpx;
        }

        .value {
          flex: 1;
          color: #333;
          font-size: 28rpx;

          &.remark {
            color: #666;
          }
        }
      }
    }

    .time-axis {
      border-top: 1rpx solid #eee;
      padding-top: 20rpx;
      margin-top: 20rpx;
      display: flex;
      justify-content: space-between;
      color: #999;
      font-size: 24rpx;
    }
  }
}

.empty-tips {
  text-align: center;
  padding: 100rpx 0;

  .empty-img {
    width: 200rpx;
    height: 200rpx;
    opacity: 0.6;
  }

  .empty-text {
    display: block;
    color: #999;
    margin-top: 20rpx;
  }
}

.add-btn {
  position: fixed;
  right: 40rpx;
  bottom: 100rpx;
  width: 100rpx;
  height: 100rpx;
  background: #4CAF50;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8rpx 24rpx rgba(76,175,80,0.3);
}
</style>